//
//  Defines.h
//  GTTool
//
//  Created by GTO on 2018/8/24.
//  Copyright © 2018年 GTO. All rights reserved.
//

#ifndef Defines_h
#define Defines_h

#pragma mark -
#pragma mark 基础设置

#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)   //屏幕宽度
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height) //屏幕高度
#define Scale_WIDTH     SCREEN_WIDTH/375.0f
#define Scale_HEIGHT    SCREEN_HEIGHT/375.0f
#define IPHONEXHEIHT    812
#define IPHONEXNAVHeight 108
#define  MC_iPhoneX (MCSCREENWIDTH == 375.f && MCSCREENHEIGH == 812.f ? YES : NO)
#define  SafeBottomMargin (MC_iPhoneX ? 34.f : 0.f)
#define  StatusBarAndNavigationBarHeight (MC_iPhoneX ? 88.f : 64.f)
#define  StatusBarHeight      (MC_iPhoneX ? 44.f : 20.f)

#pragma mark -
#pragma mark frame设置
#define Width(v)                CGRectGetWidth((v).frame)
#define Height(v)               CGRectGetHeight((v).frame)

#define MinX(v)            CGRectGetMinX((v).frame) // 获得控件屏幕的x坐标
#define MinY(v)            CGRectGetMinY((v).frame) // 获得控件屏幕的Y坐标

#define MidX(v)            CGRectGetMidX((v).frame) //横坐标加上到控件中点坐标
#define MidY(v)            CGRectGetMidY((v).frame) //纵坐标加上到控件中点坐标

#define MaxX(v)            CGRectGetMaxX((v).frame) //横坐标加上控件的宽度
#define MaxY(v)            CGRectGetMaxY((v).frame) //纵坐标加上控件的高度
#pragma mark -
#pragma mark 颜色转换
// -----------------------颜色--------------------------
#define ColorRGB(r,g,b)     [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]

#define kUIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue &0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

#define PLColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]

#pragma mark -
#pragma mark 沙盒相关
///documen 路径
#define MCDocumentPath [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]
///沙盒路径
#define MCTempPath NSTemporaryDirectory()
/// cache路径
#define MCCachePath [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]

#pragma mark -
#pragma mark 常用

#define MCApplication        [UIApplication sharedApplication]
#define MCKeyWindow          [UIApplication sharedApplication].keyWindow
#define MCAppDelegate        [UIApplication sharedApplication].delegate
#define MCUserDefaults      [NSUserDefaults standardUserDefaults]
#define MCNotificationCenter [NSNotificationCenter defaultCenter]

#pragma mark -
#pragma mark 版本区分
///手机系统版本 返回float
#define MCDEVICESYSTEMVERSION [[[UIDevice currentDevice] systemVersion] floatValue]
///当前APP版本 string
#define MCAPPVERSION [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
///当前APP build版本 string
#define MCAPPBUILD [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]
/// 设备id
#define MCDEVICEID [[[UIDevice currentDevice] identifierForVendor] UUIDString]

#ifndef MCiOS6Later
#define MCiOS6Later (MCDEVICESYSTEMVERSION >= 6)
#endif
#ifndef MCiOS7Later
#define MCiOS7Later (MCDEVICESYSTEMVERSION >= 7)
#endif
#ifndef MCiOS8Later
#define MCiOS8Later (MCDEVICESYSTEMVERSION >= 8)
#endif
#ifndef MCiOS9Later
#define MCiOS9Later (MCDEVICESYSTEMVERSION >= 9)
#endif
#ifndef MCiOS10Later
#define MCiOS10Later (MCDEVICESYSTEMVERSION >= 10)
#endif
#ifndef MCiOS11Later
#define MCiOS11Later (MCDEVICESYSTEMVERSION >= 11)
#endif

//-------------------打印消息------------------
#ifdef DEBUG

#define NSLog(FORMAT, ...) fprintf(stderr, "%s:%zd\t%s\n", [[[NSString stringWithUTF8String: __FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat: FORMAT, ## __VA_ARGS__] UTF8String]);

#else

#define NSLog(FORMAT, ...) nil

#endif


#pragma mark -
#pragma mark 字符串操作
/**
 字符串去除两端空格
 
 @param string 字符串
 @return 字符串
 */
#define MCTrim(string) [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
/**
 删除字符串空格
 
 @param string 字符串
 @return 字符串
 */
#define MCDelSpace(string) while([string containsString:@" "]){string=[string stringByReplacingOccurrencesOfString:@" " withString:@""];}

#pragma mark -
#pragma mark 为空判断
/**
 字符串判空
 @param string 字符串
 @return 是否为空
 */
#define MCStringIsEmpty(string) ([string isKindOfClass:[NSNull class]] || string == nil || [string length] < 1 ? YES : NO )
/**
 数组判空
 @param array 数组
 @return 是否为空
 */
#define MCArrayIsEmpty(array) (array == nil || [array isKindOfClass:[NSNull class]] || array.count == 0? YES : NO)
/**
 数组判空
 @param array 数组
 @return 是否为空
 */
#define MCArrayEmpty(array) (array == nil || [array isKindOfClass:[NSNull class]] || array.count == 0? YES : NO)
/**
 字典判空
 @param dictionary 字典
 @return 是否为空
 */
#define MCDictionaryIsEmpty(dictionary)  (dictionary == nil || [dictionary isKindOfClass:[NSNull class]] || dictionary.allKeys.count == 0? YES : NO)
/**
 对象判空
 @param object 对象
 @return 是否为空
 */
#define MCObjectIsEmpty(object)  (object == nil||[object isKindOfClass:[NSNull class]]||([object respondsToSelector:@selector(length)] && [(NSData *)object length] == 0)|| ([object respondsToSelector:@selector(count)] && [(NSArray *)object count] == 0)?YES:NO)

#endif /* Defines_h */
